/**
 * @Author: 陈瑞鹏
 * @Date:   2021-11-08 19:19:24
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2022-08-29 15:45:35
 */
import { MediatorGameScene } from "./MediatorGameScene";
import { INotification } from "../pureMvc/Interfaces";

const { ccclass, property } = cc._decorator;

@ccclass

export default class BaseGameScene extends cc.Component {

  protected mediator: MediatorGameScene = null;

  public m_bIsRuning: boolean = false;

  public customData: any = null;

  private canvas: cc.Canvas = null;

  protected depsRes: Array<string> = null;


  public onLoad(): void {

    this.mediator = this.mediator || new MediatorGameScene(this.getClassName(), this);
    this.mediator.registerMediator();

    if (!cc.sys.isMobile) {
      cc.view.setFrameSize(1334, 750);
      let c = this.node.getComponent(cc.Canvas);
      c.fitHeight = true;
      c.fitWidth = true;
    }
  }

  public getClassName(): string {

    return this.node.name;
  }

  public sendNotification(name: string, body: any = null, type: string = null): void {
    if (this.mediator)
      this.mediator.sendNotification(name, body, type);
  }

  public onDestroy(): void {
  }

  public onDisable(): void {
    this.onDestroyScene();
    this.mediator.removeMediator();
  }

  /** pureMVC 消息监听列表 */
  public listNotificationInterests(): string[] {
    return [];
  }

  /**
   * pureMVC消息监听处理函数
   * @notification 消息体
   */
  public handleNotification(notification: INotification): void {

  }
  /*************************************** 弹出层接口实现 START ***************************************/

  /** 获取该节点的显示对象 (绑定pureMVC的弹出层视图由三个类型构成 Component/MediatorGameLayer/IGameLayer ) */
  public getDisplayView(): cc.Node {
    return this.node;
  }
  /*************************************** 弹出层接口实现 END ***************************************/

  public onDestroyScene(): void {
  }
}